package cate.common.table.item.kitchenware.sheet;

import cate.common.table.ESheet;
import cate.common.table.item.kitchenware.row.KitchenwareSkillRow;
import cate.common.util.random.RWList;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class KitchenwareSkillSheet extends ESheet<KitchenwareSkillRow> {
    @Override
    public String getSheetName() {
        return "厨具技能";
    }

    /**
     * 根据分组随机抽技能，同时过滤相同原型id的技能
     */
    public KitchenwareSkillRow randomSkill(int groupId) {
        return randomSkill(groupId, Collections.emptyList());
    }

    public KitchenwareSkillRow randomSkill(int groupId, List<Integer> excludes) {
        RWList<KitchenwareSkillRow> rwl = new RWList<>();
        rwl.addAndSetup(getList().stream().filter(e -> e.skillGroup == groupId && !excludes.contains(e.skillProtoId)).collect(Collectors.toList()));
        return rwl.get();
    }

    public KitchenwareSkillRow findGroupProtoRow(int groupId, int protoId) {
        return getList().stream().filter(e -> e.skillGroup == groupId && e.skillProtoId == protoId).findAny().orElse(null);
    }
}
